/*
 * @Author: szx
 * @Date: 2022-02-14 12:38:50
 * @LastEditTime: 2022-02-14 13:04:47
 * @Description:
 * @FilePath: \leetcode\500-599\540\540.js
 */
/**
 * @param {number[]} nums
 * @return {number}
 */
var singleNonDuplicate = function (nums) {
    let left = 0,
        right = nums.length - 1;
    while (left < right) {
        const mid = Math.floor((left + right) / 2);
        if (mid % 2 == 0) {
            if (nums[mid] == nums[mid + 1]) left = mid + 1;
            else right = mid;
        } else {
            if (nums[mid] == nums[mid - 1]) left = mid + 1;
            else right = mid;
        }
    }
    return nums[left];
};
console.log(singleNonDuplicate([3, 3, 7, 7, 11, 11, 12]));
